package schoiolword;

import java.util.InputMismatchException;
import java.util.Scanner;

//自定义一个异常类
class OutOfRangeException extends Exception {
    public OutOfRangeException(String msg) {
        super(msg);
    }
}

public class Test1 {
    public static void main(String[] args) {
        try {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入1~3之间的数字: ");
            int index = scanner.nextInt();
            if (index == 1) {
                System.out.println("Java语言程序设计");
            } else if (index == 2) {
                System.out.println("C语言程序设计");
            } else if (index == 3) {
                System.out.println("Python语言程序设计");
            } else {
                throw new OutOfRangeException("超出范围");
            }
        } catch (OutOfRangeException e) {
            System.out.println(e.getMessage());
        } catch (InputMismatchException ie) {
            System.out.println(ie.toString());
        }catch (Exception e) {
            e.printStackTrace();
        }finally {
            System.out.println("欢迎提出建议");
        }
    }
}
